home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Games of Daze
/
Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso
/
x2ftp
/
msdos
/
libs
/
dlbox_2
/
using.doc
< prev
Wrap
Text File
|
1995-02-27
|
12KB
|
258 lines
DLBOX 2.0
COPYRIGHT 1995 Allegory Software & William Hatcher All Rights Reserved
DISCLAIMER OF WARRANTY
ALLEGORY SOFTWARE AND WILLIAM HATCHER (HEREIN REFERRED TO AS THE
LICENSOR) HEREBY DISCLAIMS ALL WARRANTIES RELATING TO THIS SOFTWARE,
WHETHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE. THE PERSON USING THE SOFTWARE BEARS ALL RISK AS TO THE QUALITY
AND PERFORMANCE OF THE SOFTWARE. THE LICENSOR WILL NOT BE LIABLE FOR
ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, INDIRECT OR SIMILAR DAMAGES DUE
TO LOSS OF DATA OR ANY OTHER REASON, EVEN IF THE LICENSOR OR AN
AGENT OF THE LICENSOR HAS BEEN ADVISED OF THE POSSIBLITY OF SUCH DAMAGES.
IN NO EVENT SHALL THE LICENSOR'S LIABILITY FOR ANY DAMAGES EVER EXCEED
THE PRICE PAID FOR THE LICENSE TO USE THE SOFTWARE, REGARDLESS OF THE FORM
OF THE CLAIM.
THIS SOFTWARE AND MANUAL ARE SOLD "AS IS" AND WITHOUT WARRANTIES AS TO
PERFORMANCE OF MERCHANTABILITY OR ANY OTHER WARRANTIES WHETHER EXPRESSED
OR IMPLIED. BECAUSE OF THE VARIOUS HARDWARE AND SOFTWARE ENVIRONMENTS
INTO WHICH THIS PROGRAM MAY BE PUT, NO WARRANTY OF FITNESS FOR A PARTICULAR
PURPOSE IS OFFERED.
GOOD DATA PROCESSING PROCEDURE DICTATES THAT ANY PROGRAM BE THOROUGHLY
TESTED WITH NON-CRITICAL DATA BEFORE RELYING ON IT. THE USER MUST ASSUME
THE ENTIRE RISK OF USING THE PROGRAM. ANY LIABILITY OF THE SELLER WILL BE
LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.
THIS AGREEMENT SHALL BE CONSTRUED AND ENFORCED IN ACCORDANCE WITH THE
LAWS OF TENNESSEE. ANY ACTION OR PROCEEDING BROUGHT BY EITHER PARTY
AGAINST THE OTHER ARISING OUT OF OR RELATED TO THIS AGREEMENT SHALL BE BROUGHT
ONLY IN A FEDERAL COURT LOCATED IN TENNESSEE. THE PARTIES HEREBY CONSENT
TO JURISDICTION OF SAID COURTS.
THE USER OF DLBOX IS AUTHORIZED TO USE IT ROYALTY FREE FOR A PERIOD OF 30
CONSECUTIVE DAYS. ANY USE BEYOND THIS REQUIRES REGISTRATION. ALSO ANY USER
CREATING SOFTWARE USING THE DLBOX LIBRARY OR LIBRARIES THAT IS RELEASED FOR
PROFIT (COMMERCIAL OR SHAREWARE) MUST REGISTER THIS SOFTWARE.
HOW TO USE DLBOX 2.0
I. Use of the libraries is simple. An object class called interface_class
is the core. Include the files inter.h and mouse.h into your program and
place the appropriate DLBOX_*.LIB file in your project list. Presented below
is a short program illustrating the library.
/********** Sample Code **************/
#include "submit\actual\inter.h"
#include "mouse.h"
#include <stdio.h>
interface_class iface;
void initg()
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
errorcode = graphresult();
settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
}
void test()
{
iface.clear();
iface.addbox(174,23,292,274);
iface.addbar("The Bar Text",1);
iface.addtitle("A Sample Title",34,41,BLUE,4,SANS_SERIF_FONT);
iface.addcheckbox("A Checkbox",32,93,2,UNCHECKED);
iface.addradio("Radio Button 1.1",32,124,3,1,UNCHECKED);
iface.addradio("Radio Button 1.2",32,138,4,1,UNCHECKED);
iface.addradio("Radio Button 1.3",32,151,5,1,UNCHECKED);
iface.addline(13,112,275,112,BLUE);
iface.addlbox(25,118,179,169,BLUE);
iface.addbutton("Button 1",27,188,8,89);
iface.addbutton("Button 2",151,188,9,110);
iface.addfield("",159,232,10,10,TEXT);
iface.addfield("",10,232,10,11,NUMBER);
iface.dodialog();
printf("Checkbox status %d\n",iface.get_checkbox_info(2));
printf("Radio Button 1.1 status %d\n",iface.get_radio_info(3));
printf("Radio Button 1.2 status %d\n",iface.get_radio_info(4));
printf("Radio Button 1.3 status %d\n",iface.get_radio_info(5));
printf("Button 1 status %d\n",iface.get_button_info(8));
printf("Button 2 status %d\n",iface.get_button_info(9));
printf("Field 1 %s\n",iface.get_text_field_info(10));
printf("Field 2 %d\n",iface.get_text_field_info(11));
}
main()
{
initg();
test();
}
/********** Sample Code End**************/
Breakdown of program:
First of all the graphics mode must be initialized since the dlbox library
operates in graphics mode (VGA or EGA 16 color hi res modes). The function
initg() does this. The following is an analysis of the test() function.
iface.clear();
This line must appear at the beginning of any dialog box definition. It
clears out any data left from the previously declared box and initializes
several variables.
iface.addbox(174,23,292,274);
This line must appear second in the dialog box definition. It declares the
box position and size. This line must appear before any of the items to be
placed in the box since they are defined relative to it. The first two
numbers specify the x and y coordinates of the box respectively. The second
two numbers specify the width and height respectively.
iface.addbar("The Bar Text",BLUE);
This line is optional. If included, the dialog box will have a bar across
the top with the given string. The text will be white and the background
color will be as specified by the second parameter. Only 1 bar may be
declared for the box.
iface.addtitle("A Sample Title",34,41,BLUE,4,SANS_SERIF_FONT);
This line specifies a title-or text for the box. The given string contains
the text of the title. The following two numbers (34 and 41 in this case)
specify the x and y coordinates RELATIVE TO THE BOX for the title. That is,
the top left of the dialog box is considered 0,0. The next parameter
specifies the color. The next parameter (4 in this case) is the size of the
text and the final value is the font.
iface.addcheckbox("A Checkbox",32,93,2,UNCHECKED);
This line defines a checkbox for the dialog box. The string is printed out
beside the box. The first two numbers (32 and 93 in this case) specify the
relative x and y coordinates of the checkbox. The next value (2) is very
important. It is the item ID number and will be discussed later on. The
last parameter signifies whether the box should be CHECKED (ON) or UNCHECKED
(OFF) by default.
iface.addradio("Radio Button 1.1",32,124,3,1,CHECKED);
iface.addradio("Radio Button 1.2",32,138,4,1,UNCHECKED);
iface.addradio("Radio Button 1.3",32,151,5,1,UNCHECKED);
These define radio buttons. These are similar to checkboxes. The main
difference is that these are "grouped" in such a way that only one of a
particular group may be active (ON) at one time. The text for the radio
button is given in the first parameter. The next two numbers specify the
coordinates for the buttons. The next item is the item ID number (to be
discussed later). The next parameter is unique to radio buttons and is very
important. It signifies which GROUP a given radio button belongs to. Only
one of a given set of radio buttons may be CHECKED at any one time (much
like radio buttons in a car). In this case they all belong to the group
numbered 1. The final parameter signifies if a given radio button should be
CHECKED or UNCHECKED by default. Note that only one should be CHECKED to
maintain the logic of the radio button system.
iface.addline(13,112,275,112,BLUE);
The specifies a line. The coordinates specify the x and y of each end of the
line. The final parameter specifies the color.
iface.addlbox(25,118,179,169,BLUE);
Similar to the line statement, this specifies a box. This is simply a graphic
box for purposes of boxing in segments of the dialog box. The coordinates
specify the x and y coordinates of the top left and bottom right corner of the
box. The final parameter specifies the color.
iface.addbutton("Button 1",27,188,8,90);
iface.addbutton("Button 2",151,188,9,110);
These statements define standard buttons for the dialog box. The string
indicates the text to be printed on the button. The next two values are the
x and y coordinates. The next value is the item ID number (again to be
discussed later). The final value is the width of the button.
iface.addfield("",159,232,10,10,TEXT);
iface.addfield("",10,232,10,11,NUMBER);
These statements define fields for the dialog box. The first one defines a
text field and the second an integer number field. The first parameter
specifies the default text or number (in text form) to appear in the field
when it first pops up. The next two numbers are the x and y coordinates.
The next number is the width in characters of the field on the screen. The
next number is the oft-mentioned but still not explained item ID number
(below, I promise). The last parameter specifies whether the box is a TEXT
field or NUMBER field. I recommend using the TEXT field most of the time,
even for numbers. The NUMBER field type will return only integers, whereas
it is possible to use the TEXT field for number input. All that is needed
is to convert the text returned into a number using one of the appropriate
Turbo C functions.
iface.dodialog();
This is a very important statement. This statement makes the dialog box
actually happen. It therefore must appear at the end of the dialog box
definition.
What is the item ID number?
The item ID number is used to get return information from the dialog box.
Each item that will return data (Buttons, fields, check boxes and radio
buttons) must have a UNIQUE id number. This is an integer number (0-32767).
The following code illustrates getting the information back from the dialog
box. The number specified is the item ID number.
printf("Checkbox status %d\n",iface.get_checkbox_info(2));
This line gets the status of the checkbox labeled as 2. It returns an
integer 0 to indicate that the box was not checked (or Xed in actuality) and
an integer 1 to show that the box was checked.
printf("Radio Button 1.1 status %d\n",iface.get_radio_info(3));
printf("Radio Button 1.2 status %d\n",iface.get_radio_info(4));
printf("Radio Button 1.3 status %d\n",iface.get_radio_info(5));
These lines get and print the statuses of the three radio buttons. As with
checkboxes, the return is integer 1 if the box was checked and 0 if not.
Only one of a given radio group should be returned. (Note that only the id
number is needed to access the data. The radio group id is not needed.)
printf("Button 1 status %d\n",iface.get_button_info(8));
printf("Button 2 status %d\n",iface.get_button_info(9));
These lines get the statuses of the given buttons. Integer 1 indicates the
indicated button was pressed and integer 0 means it wasn't.
printf("Field 1 %s\n",iface.get_text_field_info(10));
printf("Field 2 %d\n",iface.get_text_field_info(11));
These lines give the return info for the fields. The first one returns a
string since it was declared as a text field. The second one returns an
integer since it was declared as a number field.
IMPORTANT POINTS TO KNOW
1. The order the items are added to the interface indicates the order in
which they will appear in sequence if one uses the TAB key to go from one
to the next.
2. Each active item (buttons, checkboxes, fields, radio buttons) MUST have a
UNIQUE item ID number since this is how information is retrieved from the
box.
3. All needed information must be retrieved from the box before clearing
the box and setting up a new one. A new box will zap the data from the old
one.
4. The mouse object is available through the interface_class object as mouse.
With iface declared as interface_class, a typical mouse call might be:
iface.mouse.show(); /* shows mouse */
5. There is nothing to prevent items from being specified to be drawn outside
the dialog box. In fact, this might be useful in some situations.
6. There MUST be at least one button (or picture button) in a dialog box.
Buttons are the only means of completing or exiting a dialog box.
7. Picture buttons return information is accessed with get_button_info
just like regular buttons.
8. The dialog box editor program generates item id numbers. These may be
changed as needed. They are in the sequence that items were added to the
box.
--Will Hatcher
hatcher@delphi.com